Meghan Trainor says Demi Lovato’s openness about her battles and troubles helped her cope with her own struggles.